//============================================================
// Producnt name:		Wz
// Version: 			1.0
// Coded by:			Wz (13066628480@163.com)
// Auto generated at: 	2016/10/26 20:21:37
//============================================================

using System;
using System.Collections.Generic;
using System.Text;
using Cloud.Model;
using System.Data.SqlClient;
using System.Data;
namespace Cloud.DAL
{
	public static class YqsqbtyService
	{
		#region SqlCommandText
		private const string Save_CommandText = "insert into Yqsqbty values(@sjid,@sfzb)";
		private const string Update_CommandText = "Update Yqsqbty set sjid = @sjid,sfzb = @sfzb where id = @id";
		private const string Delete_CommandText = "delete from Yqsqbty where id = @id";
		private const string FindAll_CommandText = "select * from Yqsqbty";
		private const string FindById_CommandText = "select * from Yqsqbty where id=@id";
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region Save
		public static int Save(Yqsqbty yqsqbty)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@sjid",SqlDbType.Int),
				new SqlParameter("@sfzb",SqlDbType.Int)
				};
			pars[0].Value=yqsqbty.Sjid;
			pars[1].Value=yqsqbty.Sfzb;
	
			return DBHelper.ExecuteNonQuery(Save_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Update
		public static int Update(Yqsqbty yqsqbty)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int),
				new SqlParameter("@sjid",SqlDbType.Int),
				new SqlParameter("@sfzb",SqlDbType.Int)
				};
			pars[0].Value=yqsqbty.Id;
			pars[1].Value=yqsqbty.Sjid;
			pars[2].Value=yqsqbty.Sfzb;
	
			return DBHelper.ExecuteNonQuery(Update_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region Delete
		public static int Delete(Yqsqbty yqsqbty)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int)
				};
			pars[0].Value=yqsqbty.Id;
	
			return DBHelper.ExecuteNonQuery(Delete_CommandText,CommandType.Text,pars);
		}
		#endregion
		
		#region FindAll
		public static IList<Yqsqbty> FindAll()
		{
			return CommonQuery(FindAll_CommandText,CommandType.Text,null);
		}
		#endregion
		
		#region FindById
		public static Yqsqbty FindById(Int32 id)
		{
			SqlParameter[] pars = new SqlParameter[]{
				new SqlParameter("@id",SqlDbType.Int)
			};	
			pars[0].Value = id;
			IList<Yqsqbty> list = CommonQuery(FindById_CommandText,CommandType.Text,pars);
			return list.Count > 0 ? list[0] : null;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
		
		#region CommonQuery
		private static IList<Yqsqbty> CommonQuery(string commandText, CommandType cmdType, SqlParameter[] pars)
		{
			IList<Yqsqbty> list = new List<Yqsqbty>();
			Yqsqbty yqsqbty = null;
			
			using (SqlDataReader reader = DBHelper.ExecuteQuery(commandText,cmdType,pars))
           	{
				while(reader.Read())
				{
					yqsqbty = new Yqsqbty();
					yqsqbty.Id = Convert.ToInt32(reader["id"]);
					yqsqbty.Sjid = Convert.ToInt32(reader["sjid"]);
					yqsqbty.Sfzb = Convert.ToInt32(reader["sfzb"]);
					
					list.Add(yqsqbty);
				}
            }
            return list;
		}
		#endregion
		
		#region ??
		
		#endregion
		
		#region ??
		
		#endregion
	}
}



